import type { FieldRule } from 'vant'
/* 
    提取表单校验规则，为了其他页面复用
*/

/* 手机号校验 */
const mobileRules: FieldRule[] = [
  { required: true, message: '请输入手机号' },
  { pattern: /^1[3-9]\d{9}$/, message: '手机号格式不正确' }
]

/* 密码校验 */
const passwordRules: FieldRule[] = [
  { required: true, message: '请输入密码' },
  // \w 是所有字符
  { pattern: /^\w{8,24}$/, message: '密码需8-24个字符' }
]

/* 验证码校验 */
const mobileCodeRules: FieldRule[] = [
  { required: true, message: '请输入验证码' },
  { pattern: /^\d{6}$/, message: '验证码为6位数字' }
]

// 导出
export { mobileRules, passwordRules, mobileCodeRules }
